import random



def trans():
    str_list = []
    int_list = []
    while True:
        try:
            res = yield
            if res == 'erro':
                # print('str_list=', str_list, 'int_list=', int_list)
                return str_list,int_list

            elif type(res) == str:
                str_list.append(res)
            elif type(res) == int:
                int_list.append(res)
            else:
                # print(str_list,int_list)
                pass
        except Exception:
            return str_list,int_list

def send_value():
    t = trans()
    next(t)
    try:
        while True:
            info = input("请选择发送的类型：\n1、str\n2、int\n")
            if info == '1':
                t.send(input("请输入发送的内容:"))
            elif info == '2':
                t.send(int(input("请输入发送的内容:")))
            else:
                print("请做出正确的选择")

    except Exception:
        try:
            t.send('erro')  # t.throw(StopIteration)  也可以用throw人为的传送错误
        except StopIteration as e:
            print(e.value)


if __name__ == "__main__":
    send_value()